package com.ls.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component   //处理器加到Ioc容器中!
public class MyDateHandle implements MetaObjectHandler {

    //添加时要对标有@TableField(fill = FieldFill.INSERT)进行赋值
    // @TableField(fill = FieldFill.INSERT)  遇到此注解会调用
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("sbir",new Date (),metaObject);
    }

    //修改表数据时将sbir自动修改为最新日期
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("sbir",new Date(),metaObject);
    }
}
